package com.Wheesper.www.WheesperServer.Model;

import java.util.HashMap;
import java.util.Map;

import com.wheesper.www.WheesperServer.DAO.ContactsDAO;

public class ContactsCenter {
	private static ContactsCenter _instance = new ContactsCenter("UserCenter.data");
	public static ContactsCenter Instance() {
		return _instance;
	}
	
	private Map<String,Contacts> _email2contacts;
	
	private ContactsCenter(String dataPath) {
		_email2contacts = new HashMap<String,Contacts>();
	}
	
	public Contacts query(String email) {
		return _email2contacts.get(email);
	}
	
	public void create(User user) {
		Contacts contacts = new Contacts(user);
		_email2contacts.put(user.eMail(), contacts);
		ContactsDAO.Instance().Create(contacts);
	}
}
